package cxt.cn.community.utils;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.*;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;
import java.util.List;

/**
 * <h3>studio_backend</h3>
 * <p>接口文档配置类</p>
 *
 * @author : zhengyue
 * @date : 2020-05-15 22:00
 **/
@EnableSwagger2
@Configuration
public class SwaggerConfig {
    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                //是否启动swagger，false关闭
                .enable(true)
                .select()
                //指定要扫描的包
                .apis(RequestHandlerSelectors.basePackage("cxt.cn.community.controller"))
                .build();
    }

    //配置Swagger信息=apiInfo
    private ApiInfo apiInfo() {
        //作者信息
        Contact contact = new Contact("", "127.0.0.1:9002/", "");
        return new ApiInfo(
                "社区疫情防控",
                "personal blog",
                "1.0",
                "cxt.cn",
                contact,
                "Apache 2.0",
                "http://www.apache.org/lineses/LICENSE-2.0",
                new ArrayList()
        );
    }

}
